<script>
// console.warn('Common')
// 公共配置

import { isNotEmpty } from "@/plugins";
import moment from "moment";

const Base64 = require("js-base64").Base64;

export default {
  name: "Common",
  currentPower: "", //当前页面权限
  token: "",
  avatar: "",
  organizationID: "", //当前用户的组织机构ID
  applicationID: "", //当前用户的应用ID
  functionID: "", // 当前菜单ID
  roleID: "", // 当前角色ID
  roleType: "", //角色类型 1= 超级管理员 2=应用管理员 3=系统管理员 4=机构管理员 5=站点管理员 99=其他
  systemDefineID: "", // 当前角色ID
  roleName: "", // 当前角色名
  helpArticleID: "", // 当前帮助文档ID
  user: [], // 当前用户信息
  // uploadUrl: 'http://paper.zzj6.net:82/cloud-system/uploadFile',
  uploadUrl: process.env.VUE_APP_BASE_API + "/cloud-system/uploadFile",
  // loginUrl: '/paperLogin',
  // indexUrl: '/paperIndex/index',
  // loginUrl: "/weixingLogin",
  // indexUrl: "/weixingIndex/index",
  // loginUrl: '/telLogin',
  // indexUrl: '/telIndex/index',
  loginUrl: '/kzyLogin',
  indexUrl: '/kzyIndex/index',
  // 提示框配置
  notify: {
    duration: 3000, // 显示时间
    durationShort: 2000, // 显示时间
    durationLong: 5000, // 显示时间
  },
  // 固定下拉框
  options: {
    // ========================= 系统
    booleanTypes: [
      { key: 1, display_name: "是" },
      { key: 0, display_name: "否" },
    ],
    // 系统类型
    systemTypes: [
      { key: 1, display_name: "基础系统" },
      { key: 2, display_name: "业务系统" },
      { key: 3, display_name: "定制系统" },
    ],
    // 程序类型
    programTypes: [
      { key: 1, display_name: "内部程序" },
      { key: 2, display_name: "外部程序" },
    ],
    // 跳转模式
    jumpTypes: [
      { key: 1, display_name: "现浏览器" },
      { key: 2, display_name: "新浏览" },
    ],
    // 身份证类型
    idTypes: [
      { key: 1, display_name: "居民身份证" },
      { key: 2, display_name: "临时居民身份证" },
      { key: 3, display_name: "护照" },
      { key: 4, display_name: "军官证" },
      { key: 5, display_name: "文职干部证" },
      { key: 6, display_name: "义务兵证" },
      { key: 7, display_name: "士官证" },
      { key: 8, display_name: "文职人员证" },
      { key: 9, display_name: "职工证" },
      { key: 10, display_name: "武警警官证" },
      { key: 11, display_name: "武警士兵证" },
      { key: 12, display_name: "海员证" },
      { key: 13, display_name: "香港、澳门地区居民的港澳居民来往内地通行证" },
      { key: 14, display_name: "台湾地区居民的台湾居民来往大陆通行证" },
      { key: 20, display_name: "外籍旅客的护照" },
      { key: 30, display_name: "外交部签发的驻华外交人员证" },
      { key: 40, display_name: "外国人永久居留证等" },
    ],
    // ========================= 论文
    // 发表类型
    publishTypes: [
      { key: 1, display_name: "期刊" },
      { key: 2, display_name: "会议" },
    ],
    // 三高类型
    highTypes: [
      { key: 1, display_name: "A类" },
      { key: 2, display_name: "B类" },
      { key: 3, display_name: "C类" },
    ],
    // 预警等级
    badNoticeTypes: [
      { key: 1, display_name: "高" },
      { key: 2, display_name: "中" },
      { key: 3, display_name: "低" },
    ],
    // 服务类型
    serviceTypes: [
      { key: 1, display_name: "服务器目录" },
      { key: 2, display_name: "金枢文件服务器" },
      { key: 3, display_name: "七牛云存储" },
      { key: 4, display_name: "文件服务器（新）" },
      { key: 5, display_name: "阿里云OSS" },
      { key: 6, display_name: "金山云" },
    ],
    // 内容类型
    contentTypes: [
      { key: 1, display_name: "图片" },
      { key: 2, display_name: "文档" },
      { key: 4, display_name: "视频" },
      { key: 4, display_name: "音频" },
    ],
    // 开本
    paperTypes: [
      { key: 1, display_name: "16开" },
      { key: 2, display_name: "大16开" },
      { key: 3, display_name: "32开" },
    ],
    // 语种
    languageTypes: [
      { key: 1, display_name: "中文" },
      { key: 2, display_name: "英文" },
      { key: 3, display_name: "日语" },
      { key: 4, display_name: "德语" },
      { key: 5, display_name: "法语" },
    ],
    // 周期类型
    periodTypes: [
      { key: 1, display_name: "日报" },
      { key: 2, display_name: "周" },
      { key: 3, display_name: "半月" },
      { key: 4, display_name: "月" },
      { key: 5, display_name: "双月" },
      { key: 6, display_name: "季刊" },
      { key: 7, display_name: "半年" },
      { key: 8, display_name: "年度" },
      { key: 10, display_name: "其他" },
    ],
    signinTypes: [
      { key: 1, display_name: "在线签到" },
      { key: 2, display_name: "线下签到" },
    ],
    // ========================= 卫星
    // 器件类型
    partTypes: [
      { key: 1, display_name: "Cp	耦合器" },
      { key: 2, display_name: "LpTx	电缆损耗" },
      { key: 3, display_name: "LnTx	回传链路损耗" },
      { key: 4, display_name: "GaTx	发射天线增益" },
      { key: 5, display_name: "FlTx	发馈线损耗" },
      { key: 6, display_name: "TxChnCali	发射链路校准" },
      { key: 11, display_name: "CI_ICI	CI耦合器（考虑该参数用于标记耦合器）" },
      { key: 12, display_name: "CR_ ICR	CR耦合器（考虑该参数用于标记耦合器）" },
      { key: 13, display_name: "GaRx	接收链路天线增益" },
      { key: 14, display_name: "FLRx	接收链路馈线损耗" },
      { key: 15, display_name: "GdRx	接收链路增益" },
      { key: 16, display_name: "FreqResponse	接收链路频响" },
    ],
    // 数据来源类型
    dataTypes: [
      { key: 1, display_name: "标准数据" },
      { key: 2, display_name: "事先校准" },
      { key: 3, display_name: "实时测量" },
    ],
    // 数据类型名称
    dataTypeNames: [
      { key: 1, display_name: "唯一ID， 对应的是char(36)" },
      { key: 2, display_name: "小时分钟， 对应的是 char（5） 08：30" },
      { key: 3, display_name: "时分秒，对应的是char（8）19：08：08" },
      { key: 4, display_name: "年月日 ，对应的是 date 或 datetime" },
      { key: 5, display_name: "时间戳，对应的是年月日时分秒" },
      { key: 6, display_name: "整数，对应的是 正负整数，int" },
      { key: 7, display_name: "小数，对应的是 浮点数字， money" },
      { key: 8, display_name: "短文本，对应的是 nvarchar，长度在 1- 2000" },
      { key: 9, display_name: "长文本，对应的是 ntext，可无限长度" },
      { key: 10, display_name: "序列号，字段类型 ID，来自序列号定义表" },
      { key: 11, display_name: "分类，字段类型ID，来自分类表" },
      { key: 12, display_name: "单一对象参考， 来自其他表的数据" },
      { key: 13, display_name: "多选对象参考，来自其他表的数据，是多选的" },
      { key: 14, display_name: "链式对象参考，来自其他表的数据，是层级链的" },
      {
        key: 15,
        display_name: "是否真假， 对应int类型，1=真，0=假，其他也是假",
      },
      { key: 16, display_name: "单选状态类型，对应int类型" },
      { key: 17, display_name: "多选状态类型，对应字符串类型" },
      { key: 18, display_name: "图片" },
      { key: 19, display_name: "视频" },
      { key: 20, display_name: "文档" },
    ],
  },
  methods: {
    // 列表时间格式化方法
    dateTimeFormat: function (date) {
      if (!isNotEmpty(date)) {
        return "";
      }
      return moment(date).format("YYYY-MM-DD HH:mm:ss");
    },
    dateFormat: function (date) {
      if (!isNotEmpty(date)) {
        return "";
      }
      return moment(date).format("YYYY-MM-DD");
    },
    yearFormat: function (date) {
      if (!isNotEmpty(date)) {
        return "";
      }
      return moment(date).format("YYYY");
    },
    HMSFormat: function (date) {
      if (!isNotEmpty(date)) {
        return "";
      }
      return moment(date).format("HH:mm:ss");
    },
    strFormat: function (str) {
      if (!isNotEmpty(str)) {
        return "";
      }
      return str.replace(/,/g, "，");
    },
    zDeBase64: function (data) {
      return isNotEmpty(data)
        ? Base64.decode(data).replace(/#/g, "=").replace(/\$/g, "+")
        : "";
    },
    getTopButtonType(item, i) {
      switch (item) {
        case "top_add":
          return i === 1
            ? "primary"
            : i === 2
            ? "el-icon-edit"
            : i === 3
            ? "新增"
            : i === 4
            ? ""
            : "";
        case "top_batchDelete":
          return i === 1
            ? "danger"
            : i === 2
            ? "el-icon-delete"
            : i === 3
            ? "批量删除"
            : i === 4
            ? ""
            : "";
        case "top_batchLock":
          return i === 1
            ? "warning"
            : i === 2
            ? "el-icon-lock"
            : i === 3
            ? "批量锁定"
            : i === 4
            ? ""
            : "";
        case "top_batchUnlock":
          return i === 1
            ? "info"
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "批量解锁"
            : i === 4
            ? ""
            : "";
        case "top_helpArticle":
          return i === 1
            ? "success"
            : i === 2
            ? "el-icon-bell"
            : i === 3
            ? "帮助"
            : i === 4
            ? ""
            : "";
        case "top_batchTaskReport":
          return i === 1
            ? "primary"
            : i === 2
            ? "el-icon-download"
            : i === 3
            ? "批量导出报告"
            : i === 4
            ? ""
            : "";
      }
      return "";
    },
    getListButtonType(item, i) {
      switch (item) {
        case "list_edit":
          return i === 1
            ? this.listIcon.update
            : i === 2
            ? "el-icon-edit"
            : i === 3
            ? "编辑"
            : i === 4
            ? ""
            : "";
        case "list_delete":
          return i === 1
            ? this.listIcon.delete
            : i === 2
            ? "el-icon-delete"
            : i === 3
            ? "删除"
            : i === 4
            ? ""
            : "";
        case "list_lock":
          return i === 1
            ? this.listIcon.lock
            : i === 2
            ? "el-icon-lock"
            : i === 3
            ? "锁定"
            : i === 4
            ? ""
            : "";
        case "list_unlock":
          return i === 1
            ? this.listIcon.unLock
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "解锁"
            : i === 4
            ? ""
            : "";
        case "list_author":
          return i === 1
            ? this.listIcon.author
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "作者"
            : i === 4
            ? ""
            : "";
        case "list_publishFee":
          return i === 1
            ? this.listIcon.publishFee
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "版面费"
            : i === 4
            ? ""
            : "";
        case "list_commitment":
          return i === 1
            ? this.listIcon.commitment
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "科研诚信承诺书"
            : i === 4
            ? ""
            : "";
        case "list_examine":
          return i === 1
            ? this.listIcon.examine
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "论文发表审批表"
            : i === 4
            ? ""
            : "";
        case "list_cancelPaper":
          return i === 1
            ? this.listIcon.cancelPaper
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "撤稿"
            : i === 4
            ? ""
            : "";
        case "list_qianzi":
          return i === 1
            ? this.listIcon.qianzi
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "版面费签字"
            : i === 4
            ? ""
            : "";
        case "list_paper":
          return i === 1
            ? this.listIcon.paper
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "论文全文"
            : i === 4
            ? ""
            : "";
        case "list_dengjibiao":
          return i === 1
            ? this.listIcon.dengjibiao
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "论文发表登记表"
            : i === 4
            ? ""
            : "";
        case "list_keyanketi":
          return i === 1
            ? this.listIcon.keyanketi
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "科研题目"
            : i === 4
            ? ""
            : "";
        case "list_taskChain":
          return i === 1
            ? this.listIcon.taskChain
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "任务链路"
            : i === 4
            ? ""
            : "";
        case "list_taskStep":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "任务步骤"
            : i === 4
            ? ""
            : "";
        case "list_count":
          return i === 1
            ? this.listIcon.count
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "计算公式"
            : i === 4
            ? ""
            : "";
        case "list_taskPlanItem":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "任务列表"
            : i === 4
            ? ""
            : "";
        case "list_telReturnFee":
          return i === 1
            ? this.listIcon.telReturnFee
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "退费"
            : i === 4
            ? ""
            : "";
        case "list_telAgainstPro":
          return i === 1
            ? this.listIcon.telAgainstProcess
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "投诉处理"
            : i === 4
            ? ""
            : "";
        case "list_telVisit":
          return i === 1
            ? this.listIcon.telVisit
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "回访"
            : i === 4
            ? ""
            : "";
        case "list_Instrument":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "任务列表"
            : i === 4
            ? ""
            : "";
        case "list_taskDefineIndicator":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "任务定义测量指标列表"
            : i === 4
            ? ""
            : "";
        case "list_antenna":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "天线列表"
            : i === 4
            ? ""
            : "";
        case "list_copy":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "数据另存为"
            : i === 4
            ? ""
            : "";
        case "list_stationSatellite":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "卫星列表"
            : i === 4
            ? ""
            : "";
        case "list_taskDefineStep":
          return i === 1
            ? this.listIcon.taskStep
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "任务定义步骤"
            : i === 4
            ? ""
            : "";
        case "list_batchData":
          return i === 1
            ? this.listIcon.distributeDirver
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "批量创建数据"
            : i === 4
            ? ""
            : "";
        case "list_chainFreqData":
          return i === 1
            ? this.listIcon.detail
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "链路频率校准数据"
            : i === 4
            ? ""
            : "";
        case "list_chainFreqDataUpExcel":
          return i === 1
            ? this.listIcon.submit
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "链路频率校准数据导入"
            : i === 4
            ? ""
            : "";
        case "list_page":
          return i === 1
            ? this.listIcon.paper
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "跳转仪器面板"
            : i === 4
            ? ""
            : "";
        case "list_taskReport":
          return i === 1
            ? this.listIcon.download
            : i === 2
            ? "el-icon-unlock"
            : i === 3
            ? "导出报告"
            : i === 4
            ? ""
            : "";
        case "list_field":
          return i === 1
            ? this.listIcon.update
            : i === 2
            ? "el-icon-edit"
            : i === 3
            ? "字段列表"
            : i === 4
            ? ""
            : "";
        case "list_refresh":
          return i === 1
            ? this.listIcon.update
            : i === 2
            ? "el-icon-edit"
            : i === 3
            ? "数据库表舒心"
            : i === 4
            ? ""
            : "";
      }
      return "";
    },
  },
};
</script>
<style>
.el-select-dropdown__list li:last-child {
  height: 50px;
}

.listIcon {
  width: 20px !important;
  height: 20px !important;
  margin-left: 10px;
}

.listIcon:hover {
  cursor: pointer;
}
</style>
